﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Baza.EF.DAL;
using Baza.EF.BLL;


namespace Pep_3014_3070_Desktop
{
    public partial class RemoveApartment : Form
    {
        public RemoveApartment()
        {
            InitializeComponent();
        }

        private void RemoveApartment_Load(object sender, EventArgs e)
        {
            cmbIznajmljivac.DataSource = DAIznajmljivaciApartmani.SelectOwners();
            cmbIznajmljivac.DisplayMember = "FirstName";

        }

        private void cmbIznajmljivac_Format(object sender, ListControlConvertEventArgs e)
        {
            string lastname = ((Owners)e.ListItem).FirstName;
            string firstname = ((Owners)e.ListItem).LastName;
            e.Value = lastname + " " + firstname;
        }



        private void btnOdustani_Click(object sender, EventArgs e)
        {
            this.Close();
        }



        private void cmbIznajmljivac_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbApartman.DisplayMember = "";
            Owners owner = (Owners)cmbIznajmljivac.SelectedItem;
            cmbApartman.DataSource = DAIznajmljivaciApartmani.SelectApartmentBYOwner(owner);
            cmbApartman.DisplayMember = "Title";

        }

        private void btnUkloni_Click(object sender, EventArgs e)
        {
            Apartments apartment = (Apartments)cmbApartman.SelectedItem;
            DAIznajmljivaciApartmani.RemoveApartmentByID(apartment);
            MessageBox.Show(Global.GetString("appartRem_succ"), "Apartmani", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

    }
}
